<template>
  <div class="edit_r">
    <AddressInfo :id="id" ref="aa"></AddressInfo>
    <div @click="changeAddress()" class="edit_btn">修改地址</div>
  </div>
</template>

<script>
import AddressInfo from "../components/AddressInfo.vue";
export default {
  name: "Edit",
  components: { AddressInfo },
  props: ["id"],
  methods: {
    changeAddress() {
      const uid = localStorage.getItem("uid");
      this.$axios({
        method: "POST",
        url: "http://1.15.170.222:88/api/manage/address/update",
        data: {
          id: this.$refs.aa.id,
          uid: uid,
          address: this.$refs.aa.acity + this.$refs.aa.address,
          phone: this.$refs.aa.phone,
          name: this.$refs.aa.name,
        },
      }).then((response) => {
        console.log(response);
        let code = response.data.code;
        if (code === 0) {
          this.$alert("修改成功", "提示", {
            confirmButtonText: "确定",
          });
          this.$router.push({
            name: "dizhi",
          });
        } else {
          this.$alert("服务器内部错误", "提示", {
            confirmButtonText: "确定",
          });
        }
      });
    },
  },
};
</script>

<style>
.edit_r {
  padding-top: 80px;
  display: flex;
  flex-direction: column;
  width: 1050px;
  height: 680px;
}
.edit_btn {
  margin: 10px auto;
  border-radius: 8px;
  width: 120px;
  height: 35px;
  line-height: 35px;
  text-align: center;
  font-size: 13px;
  background-color: #00bfff;
  color: #fff;
  cursor: pointer;
}
</style>
